package exercise.day06;

import java.util.Arrays;

public class MaxOfArray {
    public static void main(String[] args) {
        int a[]=new int[5];
        int max=0;
        for(int i=0;i<a.length;i++){
            a[i]=(int)(Math.random()*100);
            if(max<a[i]){
                max=a[i];
            }
            System.out.print(a[i]+" ");
        }
        System.out.println();
        System.out.println("最大值："+max);

        a=Arrays.copyOf(a,a.length+1);
        a[a.length-1]=max;
        for(int i=0;i<a.length;i++){

            System.out.print(a[i]+" ");
        }
        System.out.println();
        System.out.println();



        int[] arr=new int[10];
        int max1=0;
        for(int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            if(max1<arr[i]){
                max1=arr[i];
            }
            System.out.print(arr[i]+" ");
        }
        System.out.println();
        System.out.println("最大值："+max1);
        arr=Arrays.copyOf(arr,arr.length+1);
        for(int i=0;i<arr.length;i++){
            arr[arr.length-1]=max1;
            System.out.print(arr[i]+" ");
        }

    }
}
